Skip to content

Dividing propagules by PFT and other issues#822

Merged
davidorme merged 6 commits into750-new-branch-fruit-productionfrom
750-dividing-pft-propagules
Apr 8, 2025
Merged

Dividing propagules by PFT and other issues#822
davidorme merged 6 commits into750-new-branch-fruit-productionfrom
750-dividing-pft-propagules

Conversation

@davidorme
Copy link
Copy Markdown
Collaborator

Description

These are some changes I think we'll need in the fruit production.

  • I've tried to tackle the issue of getting fallen propagules per PFT and per cell. That involves a loop over cohorts per cell.

  • I've applied the same solution to split up the propagules and non propagule mass in the canopy by PFT. Ultimately, I think we need to rethink this bit - at the moment, reproductive mass is kinda plastic until it hits the floor and I think we might need to allocate reproductive tissue to the two classes at a cohort level.

  • I spotted a problem with the recalculation of the turnover rates - we were calculating the actual allocation using the annual rate and then only passing a timestep fraction of the productivity into the turnover pools. That meant that - for example with monthly timesteps - each month allocated a years worth of turnover but 1/12 was added to the leaf turnover and the remaining 11/12 of the leaf turnover disappeared. I've hacked the rates when the Flora is added to the model, which isn't elegant but I think will do for now.

  • There was also an issue that per stem allocations weren't being scaled up to the number of individuals in a cohort.

Contributes to fixing #750

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works
  • Relevant documentation reviewed and updated

@davidorme davidorme requested a review from Copilot April 7, 2025 14:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

virtual_ecosystem/models/plants/plants_model.py:735

  • Duplicate addition detected for canopy_n_propagules in the cohort loop. It appears that the same value is added twice, which may result in double counting; consider removing one of the duplicate updates.
self.data["canopy_n_propagules"].loc[cell_id, cohort_pft] += ( stem_n_propagules * cohort_n_stems )

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.11%. Comparing base (f5d0fd8) to head (98da0cc).

Additional details and impacted files
@@                         Coverage Diff                         @@
##           750-new-branch-fruit-production     #822      +/-   ##
===================================================================
+ Coverage                            94.10%   94.11%   +0.01%     
===================================================================
  Files                                   74       74              
  Lines                                 5246     5255       +9     
===================================================================
+ Hits                                  4937     4946       +9     
  Misses                                 309      309              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@davidorme davidorme requested a review from sallymatson April 7, 2025 18:02
# sophisticated approach.
self.data["leaf_turnover"][cell_id] = np.sum(
cohort_allocation.foliage_turnover / self.model_timing.updates_per_year
stem_allocation.foliage_turnover * cohorts.n_individuals
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that turnover values are per stem? I never realized that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup - the allocation model the GPP for a representative stem in the cohort and gives the resulting stem allocation.

Copy link
Copy Markdown
Collaborator

@sallymatson sallymatson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One optimisation question. Otherwise LGTM

@davidorme davidorme marked this pull request as ready for review April 8, 2025 10:55
@davidorme davidorme requested a review from sallymatson April 8, 2025 10:56
@davidorme davidorme merged commit 91c534f into 750-new-branch-fruit-production Apr 8, 2025
16 checks passed
@davidorme davidorme deleted the 750-dividing-pft-propagules branch April 8, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants